<?php

class Cbanner extends CI_Model {


    
function get_all_banners_com_paginacao($inicial,$numreg){

    if(!is_numeric($inicial)){
        $inicial=0;
    }
    if(!is_numeric($numreg)){
        $numreg=0;
    }

    $query = $this->db->query('SELECT * FROM mov_banners order by ban_id desc LIMIT '.$inicial.', '.$numreg);
    return $query->result();

} 

function get_all_banners(){

    $query = $this->db->query('SELECT * FROM mov_banners');
    return $query->result();

} 

function conta_registro_banners(){

    $query = $this->db->get_where('mov_banners');
    return $query->num_rows();
}
    
    
public function adicionar_novo_banner($dados){
                    
    if($this->db->insert('mov_banners', $dados)){
        return true;
    }else{
        return false;
    }
}     
    
public function solicita_dados($id){
    
    $query = $this->db->query('SELECT * FROM mov_banners where ban_id ='.$id);
    return $query->result();             

}      
    
    
public function alterar_banner($dados,$id){
        
    $this->db->update('mov_banners',$dados,array('ban_id' => $id));
    return 1;   
}     
    
public function exclui_banner($id){
                
        if($this->db->query("DELETE FROM mov_banners WHERE ban_id =".$id)){	
            return true;
        }else{
            return false;
        }
}     
    
function retorna_nome_da_img($id){
              
        $this->db->select('ban_img');
        $query = $this->db->get_where('mov_banners', array('ban_id' => $id));
        return $query->result();
}        
 
















    
    
    
}